#!/usr/bin/perl

($dir, $target, $num) = @ARGV;

&failed() unless(chdir($dir));
#&failed() if(!(-f $target) || $num <= 0);
&failed() if($num <= 0);
$target =~ s|.*/||;
$target =~ s|_| |;

foreach $n ( 1 .. $num ){
	open(FILE, ">$n") || &failed();
	print FILE "$target\n";
	close(FILE);
}
&success();

sub success {
	exit(0);
}
sub failed {
	exit(1);
}
